<%@ Register TagPrefix="uc1" TagName="StockReportHeader" Src="../UserControls/StockReportHeader.ascx" %>
<%@ Import namespace="MIMS_WRS.Web" %>
<%@ Import namespace="MIMS.WRS.Entities" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="IMStockReport.aspx.vb" Inherits="MIMS_WRS.Web.IMStockReport"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>IMStockReport</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
		<link href="../report.css" type="text/css" rel="stylesheet">
		<script language="javascript" src="../js/common.js"></script>
		<script language="javascript" src="../js/progress.js"></script>
		<script language="javascript">
		<!--
		
		window.onload = saydone;
		
		function printDocument() {
			window.document.getElementById('ActionTop').style.display = "none";
			window.document.getElementById('ActionBottom').style.display = "none";
			window.print();
			window.document.getElementById('ActionTop').style.display = "block";
			window.document.getElementById('ActionBottom').style.display = "block";
		}
		
		function callback(res) {
			var textResult = res.value;
			var arrText = textResult.split("@");
			var divAddingCart = document.getElementById(arrText[1]);
			wait(1000);
			if (res.value && arrText[0]) {
				/*
				if(arrText[0] == "1")
				{
					if(confirm("Access your partly completed shopping cart. Click OK to sign in for viewing it then access to your shopping cart."))
						openSignInDialog();
				}
				*/
				if(arrText[0] == "2")
				{
					divAddingCart.innerHTML = "";
					alert("You should select items that come from the same Consolidation Point. Please choose the Consolidation Point that you selected before.");
				}
				else if(arrText[0] != "" && arrText[0] != "1")
				{
					divAddingCart.innerHTML = "";
					alert(arrText[0]);
				}
			}
			else
			{
				divAddingCart.innerHTML = "<i>completed</i>";
			}
			divAddingCart.innerHTML = "";
		}
		
		function AddToCart(values, divAddingCartId)
		{
			var ddlFOBOrHD = window.document.getElementById('header_ddlFOBOrHD');
			var FOBOrHD = ddlFOBOrHD.options[ddlFOBOrHD.selectedIndex].value;
			
			var ddlConPoint = window.document.getElementById('header_ddlConPoint');
			var country = ddlConPoint.options[ddlConPoint.selectedIndex].value;
			
			var territoryID = 0;
			var territoryText = "";
			var ddlCountry = window.document.getElementById('header_ddlCountry');
			var countryNameForTerritory = "";
			if(ddlCountry != null && ddlCountry.selectedIndex != -1)
			{
				countryNameForTerritory = ddlCountry.options[ddlCountry.selectedIndex].text;
				
				var ddlTerritory = window.document.getElementById('header_ddlTerritory');
				if(ddlTerritory != null && ddlTerritory.selectedIndex != -1)
				{
					territoryID = ddlTerritory.options[ddlTerritory.selectedIndex].value;
					territoryText = ddlTerritory.options[ddlTerritory.selectedIndex].text;
				}
			}
			
			var divAddingCart = document.getElementById(divAddingCartId);
			divAddingCart.innerHTML = "<i>adding...</i>";
			MIMS_WRS.Web.AjaxUtilMethod.AddToShoppingCart(values,parseInt(country),parseInt(FOBOrHD),parseInt(territoryID),territoryText, divAddingCartId, countryNameForTerritory, callback);	
		}
		
		function wait(msecs)
		{
			var start = new Date().getTime();
			var cur = start
			while(cur - start < msecs)
			{
			cur = new Date().getTime();
			}
		}

		function openSignInDialog() {
				
				var url = '../Stock/UserSignIn.aspx?from=addToCart';
				var title = escape('Sign In');
				var height = 200;
				var width = 500;
				var iTop = (screen.height-height-30)/2;
				var iLeft = (screen.width/2) -100;
				
				var returnValue =  window.showModalDialog('../Dialogs/ShowDialog.aspx?title=' + title + '&src=' + url, '', 'dialogLeft: ' +iLeft+ 'px; dialogTop:' + iTop+ 'px; dialogHeight: ' + height + 'px; dialogWidth: ' + width + 'px; center: no; resizable: no; scroll: no; status: no;');
				if(returnValue == '1')
				{
					__doPostBack("refresh", "");
				}
				return false;
		}
		//-->
		</script>
		<style>
			.OrderReport SPAN.highlight { COLOR: black! important }
			.OrderReport SPAN.highlight2 { COLOR: red }
			.SpecialOffer { FONT-WEIGHT: bold; COLOR: red }
			.OrderReport1 { FONT-SIZE: 8pt; BORDER-LEFT-COLOR: black; BORDER-BOTTOM-COLOR: black; WIDTH: 100%; BORDER-TOP-COLOR: black; FONT-FAMILY: Arial, Tahoma; BORDER-COLLAPSE: collapse; BORDER-RIGHT-COLOR: black }
			.OrderReport1 TD { BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: black; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: black; PADDING-BOTTOM: 0px; BORDER-TOP-COLOR: black; PADDING-TOP: 0px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: black }
			.OrderReport1 TH { BORDER-TOP-WIDTH: 1px; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BORDER-LEFT-WIDTH: 1px; BORDER-LEFT-COLOR: black; BORDER-BOTTOM-WIDTH: 1px; BORDER-BOTTOM-COLOR: black; PADDING-BOTTOM: 0px; BORDER-TOP-COLOR: black; PADDING-TOP: 0px; BORDER-RIGHT-WIDTH: 1px; BORDER-RIGHT-COLOR: black }
			.OrderReport1 THEAD TR TH { FONT-WEIGHT: bold; COLOR: black }
		</style>
	</HEAD>
	<body ms_positioning="GridLayout">
		<form id="Form1" method="post" runat="server">
			<uc1:stockreportheader id="header" runat="server"></uc1:stockreportheader>
			<asp:Label id="lblMessage" Runat="server" CssClass="ErrorMessage" EnableViewState="False"></asp:Label>
			<asp:datalist enableviewstate="true" width="100%" id="dlReport" runat="server" cellpadding="2"
				repeatcolumns="2" borderstyle="Solid" borderwidth="1px" bordercolor="Black" gridlines="Both"
				repeatdirection="Horizontal">
				<itemstyle width="50%"></itemstyle>
				<itemtemplate>
					<table cellpadding="0" cellspacing="0" border="0" width="100%" style="table-layout:auto">
						<tr>
							<td align="left" valign="top" width="32%"><%# GetPictureHTML(DataBinder.Eval(Container.DataItem, "ProductCode")) %></td>
							<td align="left" valign="top" width="65%" style="padding-left:5px"><table class="OrderReport" cellpadding="0" cellpadding="0" border="0">
									<tr>
										<td width="1%" nowrap>Code:</td>
										<td><%# DataBinder.Eval(Container.DataItem, "ProductCode")%></td>
									</tr>
									<tr>
										<%# GetCatalogPageHTML(Container) %>
									</tr>
									<tr>
										<td width="1%" nowrap>Color:</td>
										<td><%# Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "Color"))%></td>
									</tr>
									<tr>
										<td width="1%" nowrap>Desc:</td>
										<td><%# Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "SalesDescription1"))%></td>
									</tr>
									<tr style='<%# VisibleDescription2(DataBinder.Eval(Container.DataItem, "SalesDescription2"))%>'>
										<td width="1%" nowrap></td>
										<td><%# Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "SalesDescription2"))%></td>
									</tr>
									<tr>
										<td colspan="2">
											<table class="OrderReport1" cellpadding="0" cellspacing="0" border="0" width="99%" height="5px"
												style="table-layout:fixed">
												<%# DisplayBaseOnMaxMeasurementNumber(Container.DataItem)%>
											</table>
										</td>
									</tr>
									<tr>
										<td width="1%" nowrap>Qty Available:</td>
										<td><%# GetQtyAvailHTML(Container.DataItem)%>
											<%# GetQtyAvailDesc(Container.DataItem) %>
										</td>
									</tr>
									<tr>
										<td width="1%" nowrap></td>
										<td><font color="red"><%# GetReservedQtyText(Container)%></font></td>
									</tr>
									<% if (RequestContext.TerritoryID > 0) then %>
									<tr>
										<td width="1%" nowrap>Home Delivered Price:</td>
										<td><%# Utilities.GetDecimalText(DataBinder.Eval(Container.DataItem, "HomeDelivered15Price")) %>&nbsp;<%#Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "CurrencyCode")) %>
										</td>
									</tr>
									<tr>
										<td width="1%" nowrap>For Territory:</td>
										<td><%# GetTerritory() %>
										</td>
									</tr>
									<% elseif (RequestContext.ShowFOB) then %>
									<tr>
										<td width="1%" nowrap>FOB:</td>
										<td><%# GetFOB(DataBinder.Eval(Container.DataItem, "UnitFOBPrice"), DataBinder.Eval(Container.DataItem, "Pack"), Container.DataItem)%>
										</td>
									</tr>
									<% end if%>
									<tr>
										<td width="1%" nowrap>Minimum Order:</td>
										<td><%# GetMinOrderQtyValue(DataBinder.Eval(Container.DataItem, "MinOrderQtyValue"))%><%# Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "MinOrderQty"))%>
										</td>
									</tr>
									<tr>
										<td width="1%" nowrap>Tall Pallet Qty (for info only):</td>
										<td>
											<%# Utilities.GetNormalText(DataBinder.Eval(Container.DataItem, "TallPaletQty"))%>
										</td>
									</tr>
									<tr>
										<td width="1%" nowrap>Supplier No:</td>
										<td>
											<%# DataBinder.Eval(Container.DataItem, "SupplierCode")%>
											<%# DataBinder.Eval(Container.DataItem, "TypeCode")%>
											<%# DataBinder.Eval(Container.DataItem, "OwnerCode")%>
											<%# GetClearanceStockHTML(Container) %>
											<%# DataBinder.Eval(Container.DataItem, "StockLocation")%>
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<IMG src="../Images/cart.gif">&nbsp;&nbsp;
											<asp:linkbutton id="lnkViewShoppingCart" Runat="server">Add to Cart</asp:linkbutton>
											<span id="divAddingCart" runat="server"></span>
										</td>
									</tr>
									<tr style="display:none">
										<td colspan="2"><%# DataBinder.Eval(Container.DataItem, "UnitWeight")%>
										</td>
									</tr>
								</table>
							</td>
							<td class="ItemHighlight" style="vertical-align:top; width:3%;horizotal-align:right">
								<asp:Literal id="ltrItemIndex" Runat="server"></asp:Literal></td>
						</tr>
					</table>
				</itemtemplate>
			</asp:datalist>
			<div id="ActionBottom">
			</div>
		</form>
	</body>
</HTML>
